]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add a FocusApp method to org.gnome.Shell
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 9 Jul 2011 13:30:42 +0000 (15:30 +0200)
committerGiovanni Campagna <gcampagn@redhat.com>
Mon, 2 Sep 2013 08:51:00 +0000 (10:51 +0200)
This method, which accepts a .desktop filename, is used to highlight
a specific application in the overview, for example because it has
just been created or installed.

https://bugzilla.gnome.org/show_bug.cgi?id=654086

js/ui/appDisplay.js
js/ui/overview.js
js/ui/shellDBus.js
js/ui/viewSelector.js

index 4520bdfaf8c53c1fb7a6eac0af095618249a97c3..2e2fc27e236be1466e4edf532eb3f973ea991d8e 100644 (file)
@@ -108,8 +108,38 @@ const AlphabeticalView = new Lang.Class({
                 continue;
             this._grid.addItem(this._items[id].actor);
         }
+
+        this.emit('view-loaded');
+    },
+
+    _selectAppInternal: function(id) {
+        if (this._items[id])
+            this._items[id].actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
+        else
+            log('No such application ' + id);
+    },
+
+    selectApp: function(id) {
+        if (this._items[id] && this._items[id].actor.mapped) {
+            this._selectAppInternal(id);
+        } else if (this._items[id]) {
+            // Need to wait until the view is mapped
+            let signalId = this._items[id].actor.connect('notify::mapped', Lang.bind(this, function(actor) {
+                if (actor.mapped) {
+                    actor.disconnect(signalId);
+                    this._selectAppInternal(id);
+                }
+            }));
+        } else {
+            // Need to wait until the view is built
+            let signalId = this.connect('view-loaded', Lang.bind(this, function() {
+                this.disconnect(signalId);
+                this.selectApp(id);
+            }));
+        }
     }
 });
+Signals.addSignalMethods(AlphabeticalView.prototype);
 
 const FolderView = new Lang.Class({
     Name: 'FolderView',
@@ -509,7 +539,12 @@ const AppDisplay = new Lang.Class({
             if (focused)
                 this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
         }
-    }
+    },
+
+    selectApp: function(id) {
+        this._showView(Views.ALL);
+        this._views[Views.ALL].view.selectApp(id);
+    },
 });
 
 const AppSearchProvider = new Lang.Class({
index 3fd3aa1afa5ee1c6360e430f122c0aab03bbe80a..78dcf534f3bfda0c6555bda8143508687e0bd49a 100644 (file)
@@ -265,7 +265,7 @@ const Overview = new Lang.Class({
         // Create controls
         this._controls = new OverviewControls.ControlsManager(this._searchEntry);
         this._dash = this._controls.dash;
-        this._viewSelector = this._controls.viewSelector;
+        this.viewSelector = this._controls.viewSelector;
 
         // Add our same-line elements after the search entry
         this._overview.add(this._controls.actor, { y_fill: true, expand: true });
@@ -285,11 +285,11 @@ const Overview = new Lang.Class({
     },
 
     addSearchProvider: function(provider) {
-        this._viewSelector.addSearchProvider(provider);
+        this.viewSelector.addSearchProvider(provider);
     },
 
     removeSearchProvider: function(provider) {
-        this._viewSelector.removeSearchProvider(provider);
+        this.viewSelector.removeSearchProvider(provider);
     },
 
     //
@@ -513,7 +513,7 @@ const Overview = new Lang.Class({
         this._activationTime = Date.now() / 1000;
 
         Meta.disable_unredirect_for_screen(global.screen);
-        this._viewSelector.show();
+        this.viewSelector.show();
 
         this._stack.opacity = 0;
         Tweener.addTween(this._stack,
@@ -620,7 +620,7 @@ const Overview = new Lang.Class({
         this.animationInProgress = true;
         this.visibleTarget = false;
 
-        this._viewSelector.zoomFromOverview();
+        this.viewSelector.zoomFromOverview();
 
         // Make other elements fade out.
         Tweener.addTween(this._stack,
@@ -655,7 +655,7 @@ const Overview = new Lang.Class({
         // Re-enable unredirection
         Meta.enable_unredirect_for_screen(global.screen);
 
-        this._viewSelector.hide();
+        this.viewSelector.hide();
         this._desktopFade.hide();
         this._coverPane.hide();
 
index 78a9c5b647cedb4dbb39ef2adba17749e598a9a0..802640b0d842b6cc0d883a9554bc2a1664808d20 100644 (file)
@@ -13,6 +13,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
 const Hash = imports.misc.hash;
 const Main = imports.ui.main;
 const Screenshot = imports.ui.screenshot;
+const ViewSelector = imports.ui.viewSelector;
 
 const GnomeShellIface = <interface name="org.gnome.Shell">
 <method name="Eval">
@@ -24,6 +25,9 @@ const GnomeShellIface = <interface name="org.gnome.Shell">
 <method name="ShowOSD">
     <arg type="a{sv}" direction="in" name="params"/>
 </method>
+<method name="FocusApp">
+    <arg type="s" direction="in" name="id"/>
+</method>
 <method name="GrabAccelerator">
     <arg type="s" direction="in" name="accelerator"/>
     <arg type="u" direction="in" name="flags"/>
@@ -135,6 +139,14 @@ const GnomeShell = new Lang.Class({
         Main.osdWindow.show();
     },
 
+    FocusApp: function(id) {
+        let overview = Main.overview;
+
+        overview.show();
+        overview.viewSelector.setActivePage(ViewSelector.ViewPage.APPS);
+        overview.viewSelector.appDisplay.selectApp(id);
+    },
+
     GrabAcceleratorAsync: function(params, invocation) {
         let [accel, flags] = params;
         let sender = invocation.get_sender();
index 70623291ad41a19c919a19ceeb1957013491c614..414dd33bdf00a4fe3f52c271aab1cdf56708b4b7 100644 (file)
@@ -95,8 +95,8 @@ const ViewSelector = new Lang.Class({
         this._workspacesPage = this._addPage(this._workspacesDisplay.actor,
                                              _("Windows"), 'emblem-documents-symbolic');
 
-        this._appDisplay = new AppDisplay.AppDisplay();
-        this._appsPage = this._addPage(this._appDisplay.actor,
+        this.appDisplay = new AppDisplay.AppDisplay();
+        this._appsPage = this._addPage(this.appDisplay.actor,
                                        _("Applications"), 'view-grid-symbolic');
 
         this._searchResults = new SearchDisplay.SearchResults(this._searchSystem);
@@ -525,6 +525,13 @@ const ViewSelector = new Lang.Class({
             return ViewPage.SEARCH;
     },
 
+    setActivePage: function(page) {
+        if (page == ViewPage.WINDOWS)
+            this._showPage(this._workspacesPage);
+        else
+            this._showPage(this._appsPage);
+    },
+
     fadeIn: function() {
         let actor = this._activePage;
         Tweener.addTween(actor, { opacity: 255,